import { ICanvasRenderingContext, Nullable, Vector2 } from "@babylonjs/core";
import { Container, Control } from "@babylonjs/gui";

export class Drawer {
    public static drawArrow(ctx: ICanvasRenderingContext, x: number, y: number, w: number, h: number, direction: string | undefined, color: string = '#333') {
        if(!direction) {
            return;
        }

        ctx.lineWidth = 3;
        //ctx.strokeStyle = color;


        var half_s = 12;
        var half_w = w / 2;
        var half_h = h / 2;
        ctx.beginPath();
        if(direction.indexOf('N') >= 0) {
            ctx.moveTo(x + half_w - half_s / 2, y + half_s);
            ctx.lineTo(x + half_w, y);
            ctx.lineTo(x + half_w + half_s / 2, y + half_s);
            ctx.closePath();
        }

        if(direction.indexOf('S') >= 0) {
            ctx.moveTo(x + half_w - half_s / 2, y + h - half_s);
            ctx.lineTo(x + half_w, y + h);
            ctx.lineTo(x + half_w + half_s / 2, y + h - half_s);
            ctx.closePath();
        }

        if(direction.indexOf('W') >= 0) {
            ctx.moveTo(x + half_s, y + half_h - half_s / 2);
            ctx.lineTo(x, y + half_h);
            ctx.lineTo(x + half_s, y + half_h + half_s / 2);
            ctx.closePath();
        }

        if(direction.indexOf('E') >= 0) {
            ctx.moveTo(x + w - half_s, y + half_h - half_s / 2);
            ctx.lineTo(x + w, y + half_h);
            ctx.lineTo(x + w - half_s, y + half_h + half_s / 2);
            ctx.closePath();
        }
        
        ctx.shadowOffsetX = 2;
        ctx.shadowOffsetY = 2;
        ctx.shadowBlur = 2;
        ctx.shadowColor = '#333333';

        ctx.fillStyle = color;
        ctx.fill();
        // ctx.stroke();
    }
}